package com.treasure.mall.zbq.common.ienum.order;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.treasure.mall.zbq.common.constant.Constant;
import com.treasure.mall.zbq.common.ienum.base.CodeDescCommonEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author allan
 * @date 2019-10-23
 */
public interface OrderEnums {
    @AllArgsConstructor
    @Getter
    enum DealType implements CodeDescCommonEnum {
        ORDER(0, "销售订单"),
        UPGRADE(1, "用户升级"),
        RECHARGE(2, "用户充值"),
        AUCTION(3, "拍卖保证金"),
        DEPOSIT_RECHARGE(4, "保证金充值"),
        MEMBER(5, "成为会员"),
        PARTNER(6, "成为高级合伙人"),
        ;

        private Integer code;
        private String desc;
    }

    @AllArgsConstructor
    @Getter
    enum PayType implements CodeDescCommonEnum {
        WECHAT_PAY(0, "微信小程序支付"),
        ALI_PAY(1, "支付宝"),
        BALANCE_PAY(2, "余额支付"),
        WECHAT_PAY_ANDROID(3, "微信支付(安卓)"),
        WECHAT_PAY_IOS(4, "微信支付(IOS)");

        private Integer code;
        private String desc;
    }

    @AllArgsConstructor
    @Getter
    enum RefundType implements CodeDescCommonEnum {
        ORIGINAL_WAY(0, "原路返回"),
        OFFLINE_PAY(1, "线下打款"),
        TO_BALANCE(2, "退到余额");

        private Integer code;
        private String desc;
    }

    @AllArgsConstructor
    @Getter
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum Status implements CodeDescCommonEnum {
        ACTIVE(0, "活动"),
        CLOSED(1, "交易关闭"),
        CANCEL(2, "交易取消"),
        DONE(3, "交易完成");

        private Integer code;
        private String desc;

        public String statusClass() {
            switch (this) {
                case DONE:
                case ACTIVE:
                    return Constant.COLOR_PRIMARY;
                default:
                    return Constant.COLOR_DANGER;
            }
        }
    }

    /**
     * 发货状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    @AllArgsConstructor
    @Getter
    enum DeliverStatus implements CodeDescCommonEnum {
        TO_DELIVER(0, "待发货"),
        USER_TO_RECEIVE(1, "买家待收货"),
        ORG_TO_RECEIVE(2, "鉴定中心待收货"),
        ORG_RECEIVED(3, "鉴定中心已签收"),
        ORG_RETURNED(4, "鉴定中心已退货"),
        ORG_DELIVERED(5, "鉴定中心已发货"),
        RECEIVED(6, "已签收");

        private Integer code;
        private String desc;

        public String statusClass() {
            if (this == OrderEnums.DeliverStatus.RECEIVED) {
                return Constant.COLOR_PRIMARY;
            }
            return Constant.COLOR_WARNING;
        }
    }

    /**
     * 适用于前端的订单状态
     */
    @AllArgsConstructor
    @Getter
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum UserOrderStatus implements CodeDescCommonEnum {
        TO_PAY(0, "待付款"),
        TO_DELIVER(1, "待发货"),
        TO_RECEIVE(2, "待收货"),
        AFTER_SALE_ING(3, "售后中"),
        RECEIVED(4, "已签收");

        private Integer code;
        private String desc;
    }

    /**
     * 订单类型
     */
    @Getter
    @AllArgsConstructor
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum OrderType implements CodeDescCommonEnum {
        NORMAL(0, "普通订单"),
        AUCTION(1, "拍卖订单"),
        LIVE(2, "直播订单");

        private Integer code;
        private String desc;
    }

    /**
     * 支付状态
     */
    @AllArgsConstructor
    @Getter
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum PayStatus implements CodeDescCommonEnum {
        TO_PAY(0, "等待付款"),
        PAYED(1, "已支付"),
        TIME_OUT(2, "支付超时"),
        FAILED(3, "支付失败");

        private Integer code;
        private String desc;

        public String statusClass() {
            switch (this) {
                case TO_PAY:
                    return Constant.COLOR_WARNING;
                case PAYED:
                    return Constant.COLOR_PRIMARY;
                default:
                    return Constant.COLOR_DANGER;
            }
        }
    }

    @AllArgsConstructor
    @Getter
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum AfterSaleStatus implements CodeDescCommonEnum {
        CANCEL_APPLY(0, "取消售后"),
        APPLYING(1, "售后申请中"),
        WAIT_BUYER_DELIVER_GOODS(2, "等待买家退货"),
        WAIT_SELLER_REFUND(3, "退款中"),
        COMPLETE_APPLY(4, "售后完成"),
        REFUSE_APPLY(5, "拒绝售后"),
        WAIT_SELLER_READY_GOODS(6, "买家退货等待确认"),
        TO_REFUND(7, "待退款"),
        FAILED(8, "售后失败");

        private Integer code;
        private String desc;

        public String statusClass() {
            switch (this) {
                case COMPLETE_APPLY:
                    return Constant.COLOR_PRIMARY;
                case REFUSE_APPLY:
                case CANCEL_APPLY:
                case FAILED:
                    return Constant.COLOR_DANGER;
                default:
                    return Constant.COLOR_WARNING;
            }
        }
    }

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum AfterSaleType implements CodeDescCommonEnum {
        REFUND(0, "退款"),
        REFUND_AND_RETURN(1, "退款并退货");

        private Integer code;
        private String desc;

        AfterSaleType(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }

    @AllArgsConstructor
    @Getter
    enum DeliverRole implements CodeDescCommonEnum {
        USER(0, "用户"),
        MERCHANT(1, "商家"),
        ORG_CENTER(2, "鉴定中心"),
        PLATFORM(3, "平台");

        private Integer code;
        private String desc;
    }

    enum DeliverType implements CodeDescCommonEnum {
        PLATFORM(0, "平台发货"),
        MERCHANT(1, "商家发货"),
        IDENTIFY_ORG(2, "鉴定中心发货");

        private Integer code;
        private String desc;

        DeliverType(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }

    /**
     * 鉴定状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    enum IdentifyStatus implements CodeDescCommonEnum {
        TO_IDENTIFY(0, "待鉴定"),
        IDENTIFYING(1, "鉴定中"),
        SUCCESS(2, "已鉴定"),
        FAILED(3, "鉴定失败");

        private Integer code;
        private String desc;

        IdentifyStatus(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }

    /**
     * 订单日志操作
     */
    enum Operation implements CodeDescCommonEnum {
        CREATE(0, "订单创建"),
        PAY(1, "订单支付"),
        DELIVER(2, "订单发货"),
        TO_SELL(3, "待挂卖"),
        SELL(4, "订单挂卖");

        private Integer code;
        private String desc;

        Operation(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }


    @AllArgsConstructor
    @Getter
    enum TradeType implements CodeDescCommonEnum {
        JSAPI(0, "JSAPI"),
        APP(1, "APP"),
        ;

        private Integer code;
        private String desc;
    }
}
